package com.ecfront.test.dao;

import java.util.Iterator;
import java.util.List;

import com.ecfront.dao.SupplierDAO;
import com.ecfront.pojo.Supplier;

import junit.framework.TestCase;

public class testSupplier extends TestCase {
	private static final SupplierDAO supplierDao = (SupplierDAO)SpringUtilTest.getBean("SupplierDAO");
	//测试保存
	public void testSave(){
		Supplier supplier = new Supplier();
		supplier.setAdd("杭州天目山路");
		supplier.setContact("赵科");
		supplier.setEmail("zhaoke@qaooo.com");
		supplier.setGoods("计算机配件");
		supplier.setName("柯南电脑");
		supplier.setPhone("1234579");
		supplier.setQq(456489789);
		supplier.setWebSite("www.qaooo.com");
		supplier.setState(-1);
		supplierDao.save(supplier);
	}
	//测试提取
	public void testFindAll(){
		List list = supplierDao.findAll();
		for(Iterator iter = list.iterator();iter.hasNext();){
			Supplier s = (Supplier)iter.next();
			System.out.println(s.getAdd());
			System.out.println(s.getContact());
			System.out.println(s.getEmail());
			System.out.println(s.getGoods());
			System.out.println(s.getName());
			System.out.println(s.getPhone());
			System.out.println(s.getQq());
			System.out.println(s.getWebSite());
		}
	}
	//删除测试
	public void testDel(){
		Supplier s = new Supplier();
		s.setId(1);
		supplierDao.delete(s);
	}
	//属性测试
	public void testFindProperties(){
//		Supplier ss = new Supplier();
//		ss.setId(2);
	//	List list = supplierDao.findByExample(ss);
	//	List list = supplierDao.findBySuContact("赵科");
		List list = supplierDao.findBySuAdd("杭州天目山路");
		
		for(Iterator iter = list.iterator();iter.hasNext();){
			//System.out.println(iter.next().toString());
			Supplier s = (Supplier)iter.next();
			System.out.println(s.getAdd());
			System.out.println(s.getContact());
			System.out.println(s.getEmail());
			System.out.println(s.getGoods());
			System.out.println(s.getName());
			System.out.println(s.getPhone());
			System.out.println(s.getQq());
			System.out.println(s.getWebSite());
		}
	}
}
